package com.guazai.project.service.rpcimpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guazai.common.pojo.User;
import com.guazai.common.rpc.UserRPC;
import com.guazai.project.mapper.UserMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author qiteng
 */
@DubboService
public class userInfoRPCImpl implements UserRPC {

    @Resource
    UserMapper userMapper;

    @Override
    public User getUserByAk(String accessKey) {
        if (StringUtils.isBlank(accessKey)) {
            return null;
        }
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("accessKey", accessKey);
        User user = userMapper.selectOne(queryWrapper);
        if (user == null) {
            return null;
        }
        return user;
    }
}
